<template>
  <div class="hello">
    <h1 v-ctxmenu="menus" v-if="visible">{{ msg }}</h1>
    <button @click="visible=!visible">点击</button>
  </div>
</template>

<script>
import { ref } from "vue";
export default {
  name: "HelloWorld",
  props: {
    msg: String
  },
  setup() {
    const handler = (name) => {
      console.log("name--", name);
    };
    const menus = ref([
      { name: "点击事件1", handler },
      { name: "点击事件2", handler },
      { name: "点击事件3", handler },
      { name: "点击事件4", handler }
    ]);
    const visible = ref(true)
    return {
      menus,
      visible
    };
  },
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang="scss">
h3 {
  margin: 40px 0 0;
}
ul {
  list-style-type: none;
  padding: 0;
}
li {
  display: inline-block;
  margin: 0 10px;
}
a {
  color: #42b983;
}
</style>
